using System;

namespace iPhOwa.Exchange.Attributes
{
	/// <summary>
	/// Attribte to be applied to properties to define their Exchange full name.
	/// </summary>
	[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
	public sealed class ExchangeFieldAttribute : Attribute
	{
		private readonly string fullName;

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="fullName">Set the full name.</param>
		/// <exception cref="ArgumentException">Throws if <paramref name="fullName"/> does not contain a namespace.</exception>
		/// <exception cref="ArgumentNullException">Throws if <paramref name="fullName"/> is null.</exception>
		public ExchangeFieldAttribute(string fullName)
		{
			if(fullName == null)
			{
				throw new ArgumentNullException("fullName");
			}
			else if(!fullName.Contains(":"))
			{
				throw new ArgumentException("fullName must start with a namespace.", "fullName");
			}

			this.fullName = fullName;
		}

		/// <summary>
		/// The properties full name.
		/// </summary>
		public string FullName
		{
			get { return fullName; }
		}
	}
}